import React, { useState, useEffect } from "react";

export const useDataSource = getSourceFunc => {
    const [resource, setResource] = useState(null);

    useEffect(() => {
        (async () => {
            const response = await getSourceFunc();
            setResource(response);
        })()
    }, [getSourceFunc])

    return resource;
}